<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="zh">
<head lang="en">
    <th:block th:include="include :: header('首页')"/>
    <th:block th:include="include :: headertable"/>
</head>
<body>
<div class="panel panel-success">
    <!--  <div class="panel-heading">
          <h3 class="panel-title">搜索条件</h3>
      </div>-->
    <div class="panel-body" style="padding: 0">

        <form class="layui-form layui-col-space5">

<!--            <div class="layui-inline layui-show-xs-block">-->
<!--                <select name="code" id="code" lay-filter="code">-->

<!--                </select>-->
<!--            </div>-->
            <div class="layui-inline layui-show-xs-block">
                <select name="number" id="number" lay-filter="number">

                </select>
            </div>

            <!--<div class="layui-inline layui-show-xs-block">-->
                <!--<input type="text"  name="name" placeholder="请输入设备名称" autocomplete="off" class="layui-input">-->
            <!--</div>-->
            <!--<div class="layui-inline layui-show-xs-block">-->
                <!--<input type="text"  name="code" placeholder="请输入设备编码" autocomplete="off" class="layui-input">-->
            <!--</div>-->
            <!--<div class="layui-inline layui-show-xs-block">-->
                <!--<input type="text" name="number" placeholder="请输入设备编号" autocomplete="off" class="layui-input">-->
            <!--</div>-->
            <div class="layui-inline layui-show-xs-block">
                <button class="layui-btn" lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i>搜索
                </button>
                <button class="layui-btn" lay-submit="" lay-filter="reset"><i class="layui-icon">&#xe669;</i>重置</button>

            </div>
        </form>
    </div>
</div>

<!--删除顶栏图表-->
<!--<div id="toolbar">-->
    <!--<button id="showLine1" class="layui-btn">+ 氚图表</button>-->
    <!--<button id="showLine2" class="layui-btn">+ 气溶胶图表</button>-->
    <!--<button id="showLine3" class="layui-btn">+ 中子图表</button>-->
    <!--<button id="showLine4" class="layui-btn">+ 伽马图表</button>-->
<!--</div>-->

<table id="dataTable" lay-filter="dataTable" class="layui-table"></table>


<th:block th:include="include :: footer"/>
<th:block th:include="include :: footertable"/>
<script>
    layui.use(['table', 'form'], function () {
        var table = layui.table;
        var form = layui.form;
        getEquipmentNumber()
        form.on('submit(sreach)', function (data) {
            config.tableQuery("dataTable", data.field);
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
        form.on('submit(reset)', function (data) {
            $("#code").val = ""
        });

        //请求服务器数据
        // queryParams: function queryParams(params){
        //     var param = {
        //         pageNumber: params.pageNumber,
        //         pageSize: params.pageSize,
        //         sortName: params.sortName,
        //         sortOrder: params.sortOrder,
        //         code: $("#code").val(),
        //         name: $("#name").val()
        //     };
        //     return param;
        // }



        function operateFormatter(value, row, index) {
            var operateHtml = new Array();
            operateHtml.push(row.temperature+' ℃');
            return operateHtml.join('');
        }
        function operateFormatter1(value, row, index) {
            var operateHtml = new Array();
                operateHtml.push(row.pressureValue+' MPa');
            return operateHtml.join('');
        }

        function operateFormatter2(value, row, index) {
            var operateHtml = new Array();
            if (row.code=='01' && row.puValue != null){
                operateHtml.push(row.puValue+' Bq/m3');
            }else if (row.code == '02' && row.puValue != null){
                operateHtml.push(row.puValue+' mBq/m3');
            } else if (row.code == '03'&& row.puValue != null){
                operateHtml.push(row.puValue+' nSv/h');
            } else if (row.code == '04'&& row.puValue != null){
                operateHtml.push(row.puValue+' nSv/h');
            }else {
                operateHtml.push("--")
            }
            return operateHtml.join('');
        }


        // var operateEvents = {
        //     'click #edit': function (e, value, row, index) {
        //         json = row;
        //         config.openPageLayer("编辑", "device/addDeviceData", ['500px', '400px'], "", false);
        //     },
        //     'click #delete': function (e, value, row, index) {
        //         json = row;
        //         config.openConfirmLayer("确定删除吗？", "/ht/deviceDataDel.json", {"id": row.id}, function (data) {
        //             config.tableRefresh();
        //         })
        //     },
        // };

        // config.commGet("/ht/deviceListSimple.json",function (data) {
        //     var html=' <option value="">请选择设备类型</option>'
        //     for (var i=0;i<data.length;i++){
        //         html+=' <option value="'+data[i].code+'">'+data[i].className+'</option>'
        //     }
        //     $("#code").html(html);
        //     console.log(html)
        //     form.render()
        // })

        form.on('select(number)', function(){
            // getEquipmentNumber();
        });
        function getEquipmentNumber(){
            config.commGet('/ht/equipmentNumber.json', function (list) {
               // var numberList =  list.rows
                var number = document.getElementById("number"); //给select定义的id
                // number.innerHTML = ''
                var option1 = document.createElement("option");// 创建添加option属性
                option1.innerText = '请选择设备';
                option1.value = ""// 打印option对应的纯文本 （超级管理员、管理员）
                number.appendChild(option1);
                for (let i = 0; i < list.length; i++) {
                    var option = document.createElement("option"); // 创建添加option属性
                    option.setAttribute("handle", list[i].handle); // 给option的value添加值
                    option.innerText = list[i].handle;// 打印option对应的纯文本 （超级管理员、管理员）
                    number.appendChild(option);// 给select 添加option子标签
                }
                form.render("select");
            });
        }

        config.initTable("#dataTable", "/onlineData", [ //表头
                {field: 'id', title: '序号'}
                , {field: 'equipmentHandle', title: '设备标识'}
                , {field: 'handle', title: '数据标识'}
                , {field: 'temperature', title: '温度（℃）'}
                , {field: 'humidity', title: '湿度（%）'}
                , {field: 'co', title: '一氧化碳（ppm）'}
                , {field: 'h2s', title: '硫化氢（ppm）'}
                , {field: 'ch4', title: '甲烷（%lel）'}
                , {field: 'o2', title: '氧气（%vol）'}
                , {field: 'createTime', title: '数据发布时间'}]
            // , {title: '操作', events: operateEvents, formatter: operateFormatter}]
            , {});

        $(document).on('click', '#showLine1', function () {
            json = {};
            config.openNobtnLayer("展示图表", 'chart/tritiumLine', ['900px', '760px'], "", false);
        });
        $(document).on('click', '#showLine2', function () {
            json = {};
            config.openNobtnLayer("展示图表", 'chart/aerosolLine', ['900px', '760px'], "", false);
        });
        $(document).on('click', '#showLine3', function () {
            json = {};
            config.openNobtnLayer("展示图表", 'chart/neutronLine', ['900px', '760px'], "", false);
        });
        $(document).on('click', '#showLine4', function () {
            json = {};
            config.openNobtnLayer("展示图表", 'chart/gammaLine', ['900px', '760px'], "", false);
        });

    });


</script>

</body>
</html>
